<?php  include  $this->admin_tpl('header'); ?>
<link rel="stylesheet" type="text/css" href="<?php echo JS_PATH;?>EasyUI/themes/haidaoblue/easyui.css">
<link rel="stylesheet" type="text/css" href="<?php echo JS_PATH;?>EasyUI/themes/icon.css">
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/jquery.easyui.min.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="<?php echo JS_PATH;?>EasyUI/hd_default_config.js"></script>

<script type="text/javascript" src="<?php echo JS_PATH;?>layer/layer.js"></script>
<style type="text/css">
	.layui-layer-content{ text-align: center; }
	.layui-layer-content img{ max-height: 500px; }
</style>
<div class="content">
	<div class="site">
	<?php echo C('site_name')?> <a href="#">财务管理</a> > 交易列表
	</div>
    <div id="cc" class="easyui-calendar"></div>
	<span class="line_white"></span>
	<div class="goods mt10">
		<div class="search_ind">
			<input type="hidden" name="m" value="<?php echo GROUP_NAME ?>">
			<input type="hidden" name="c" value="<?php echo MODULE_NAME ?>">
			<input type="hidden" name="a" value="<?php echo ACTION_NAME ?>">
            <span style="margin-right: 10px;">类型</span>
            <select name='status' id='group_combbox' class="easyui-combobox" data-options="editable:false,panelHeight:'auto'" style="height: 26px; width:100px;">
                </select>
             <span style="margin-right: 10px;">开始时间 </span>
                <input class="easyui-datebox" name="start" id="start" data-options="sharedCalendar:'#cc'">
                <span style="margin-right: 10px;">至</span>
                <input class="easyui-datebox" name="end" id="end" data-options="sharedCalendar:'#cc'" validType="md['#start']">

			<span style="margin-right: 10px;">搜索查询 </span>
			<input id="keyword" class="easyui-textbox" name="keyword" style="width:210px;height: 26px;" prompt="输入会员名称查询">
			<a id="search" href="javascript:;" class="easyui-linkbutton" style="height: 26px;padding-right: 10px;">查询</a>
		</div>
		
		<div class="login mt10" style="border: none;border-right: 1px solid #e6e6e6;">
			<!-- 日志信息 -->
			<dl id="admin_moneylog" style="width:100%;"></dl>
			<!-- 财务设置 -->
		</div>
		<div class="clear"></div>
		<?php include $this->admin_tpl('copyright') ?>
	</div>
</div>
<script type="text/javascript">
var dom = $('#admin_moneylog');
var pageSize = <?php echo PAGE_SIZE?>;
var dataurl = '<?php echo U('balance1')?>';
// var delurl = '<?php echo U('delete')?>';
var keyword = '<?php echo $keyword?>';
var user_id = '<?php echo $user_id?>';
$(function(){
	dom.datagrid({
		url:dataurl,
		striped:true,
		width:'100%',
		checkOnSelect:false,
		title:"统计概览",  
		fitColumns:true,
		// toolbar:[
		// 	// {
		// 	// 	id:'delrows',
		// 	// 	text:'删除',
		// 	// 	iconCls:'icon-del',
		// 	// },'-',
		// 	// {
		// 	// 	id:'exportrows',
		// 	// 	text:'导出',
		// 	// 	iconCls:'icon-export',
		// 	// }
		// ],
		// frozenColumns:[[
		// 	{field:'id',checkbox:true}
		// ]],
		queryParams:{
			keyword:keyword
		},
		scrollbarSize:0,
		pagination:true,
		pageSize:pageSize,
		pageList: [pageSize,pageSize*4,pageSize*8,pageSize*16,pageSize*32,pageSize*64],
		//可以设置每页记录条数的列表
		columns:[[
		{field:'id',title:'ID',width:'4%',halign:'center',align:'center'},
		
		{field:'username',title:'会员帐号',width:'10%',halign:'center',align:'center',
			// formatter:function(value,row,index){
			// 	if(value!=null){
			// 		return '<a  href="/index.php?m=user&c=member&a=dologin&username='+value+'" target="_blank">'+value+'</a>'; 
			// 	}else{
			// 		return '--'; 
			// 	}
			// }
		},
		// {field:'sell_username',title:'卖方帐号',width:'7%',halign:'center',align:'center',
		// 	formatter:function(value,row,index){
		// 		if(value!=null){
		// 			return '<a  href="/index.php?m=user&c=member&a=dologin&username='+value+'" target="_blank">'+value+'</a>'; 
		// 		}else{
		// 			return '--'; 
		// 		}
		// 	}
		// },
		// {field:'order_number',title:'订单号',width:'10%',halign:'center',align:'center'},
		// {field:'number',title:'数量(GF)',width:'5%',halign:'center',align:'center',sortable:true},
		{field:'balance',title:'数量',width:'10%',halign:'center',align:'center',sortable:true},
		// {field:'charge_percent',title:'手续费(%)',width:'5%',halign:'center',align:'center',sortable:true},
		
		// {field:'price',title:'单价(GF)',width:'5%',halign:'center',align:'center',sortable:true},
		// {field:'all_price',title:'总价(GF)',width:'5%',halign:'center',align:'center',sortable:true},
		// {field:'need_pay',title:'人民币',width:'5%',halign:'center',align:'center',sortable:true},
		// {field:'pay_image',title:'交易凭证',width:'7%',halign:'center',align:'center',
		// 	formatter: function (value, row, index) { 
		// 		if(value!=null){
		// 			return "<a href='javascript:showImg(\""+value+"\") '>查看</a>";       
		// 		}else{
		// 			return "--";
		// 		} 
		// 	}
		// },

		{field:'type',title:'类型',width:'5%',halign:'center',align:'center',
			formatter:function(value,row,index){
				if(value==1) return "充值";
				if(value==2) return "提现"; 
				if(value==3) return "交易"; 
				if(value==4) return "兑换GF";
				if(value==5) return "后台操作"; 
				
			}
		},

		// {field:'user_money',title:'可用余额',width:'10%',halign:'center',align:'center',sortable:true},
		// {field:'freeze_money',title:'冻结金额',width:'10%',halign:'center',align:'center',sortable:true},
		{field:'add_time',title:'时间',width:'10%',align:'center',sortable:true,
			// formatter:function(value,row,index){
			// 	return $.fn.datebox.defaults.timeformat(value);
			// }
		},
		// {field:'msg',title:'描述',width:'20%',halign:'center',align:'center',sortable:true}
		]],
		onLoadSuccess:function(data){
			// $(".panel-title").html(data.title);
				var group = data.status;
				group.unshift({"id":"","name":"请选择"})
				$('#group_combbox').combobox({
					data:group,
					valueField:'id',
					textField:'name'
				});
		}
	});
	$('#exportrows').bind('click', function(){
			var start=$('#start').datebox('getValue');
			var end=$('#end').datebox('getValue');
			var keyword=$('#keyword').val();
			var type=$('#group_combbox').combobox('getValue');
			window.location.href="/index.php?m=user&c=admin_silver_log&a=index&act=excel&start="+start+"&end="+end+"&keyword="+keyword+"&type="+type;
		});
	//回车查询
	$('#keyword').textbox('textbox').bind('keydown',function (e) {
		if (e.keyCode == 13) {
			$('#search').trigger('click');
		}
	});
});
//增加查询参数，重新加载表格
$('#search').bind('click',function (){
	var queryParams = dom.datagrid('options').queryParams;
	//查询参数直接添加在queryParams中
	queryParams.start = $('#start').datebox('getValue');
	queryParams.end = $('#end').datebox('getValue');
	queryParams.keyword = $("#keyword").val();
	queryParams.status = $('#group_combbox').combobox('getValue');
	dom.datagrid('options').queryParams = queryParams;
	dom.datagrid('reload');
})
	function showImg(img){

		layer.open({
		  type: 1,
		  title: "交易凭证",
		  closeBtn: 1,
		  area: ['1000px','600px'],
		//  skin: 'layui-layer-nobg', //没有背景色
		  shadeClose: 0,
		  content: '<img  src="'+img+'" />'
		});
	}
</script>
